<template>
    <el-dialog title="选择用户" v-loading="selectLoading" v-model="editFormVisible" :close-on-click-modal="false" top="5%">
        <sy-baselist
                :filters="filters"
                :hideAdd="true"
                :hideEdit="true"
                :hideDel="true"
                :showSelect="true"
                @onSelect="onSelect"
                listUrl="server/system/User.ashx?cmd=GetUserList"
        >
            <el-table-column prop="FCode" label="登录名" width="100" sortable>
            </el-table-column>
            <el-table-column prop="FName" label="用户名" width="150" sortable>
            </el-table-column>
            <el-table-column prop="FNote" label="备注" width="200" sortable>
            </el-table-column>

        </sy-baselist>
    </el-dialog>
</template>

<script>
    import util from '../../common/util'
    export default {
        data(){
            return {
                selectLoading:false,
                FRoleID:0,
                editFormVisible:false,
                filters: [{type: "string",name:"FName",text:"用户名", value: ""}]
            }
        },
        methods:{
            switchLoading(flag){
                this.selectLoading = flag;
            },
            _openAdd(row) {
                this.editFormVisible = true
                this.FRoleID = row.FRoleID
            },
            onSelect(row){
                let form={
                    FRoleID:this.FRoleID,
                    FUserID:row.FID,
                    FName:row.FName
                }
                util.post("server/system/Role.ashx?cmd=SaveRoleUser",form,this.switchLoading,result=> {
                    this.editFormVisible = false
                    this.$emit("onSaveSuc",row)
                })
            }
        }
    }
</script>